﻿/* Write a program that reads a string from the console and lists all different words in the string along with information how many times each word is found. */

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace _22.ListWords
{
    class ListWords
    {
        static void Main()
        {
            string str = "find my different words bitch bitch";

            var dict = new Dictionary<string, int>();

            foreach (Match m in Regex.Matches(str, @"\w+"))
                dict[m.Value] = dict.ContainsKey(m.Value) ? dict[m.Value] + 1 : 1;

            foreach (var v in dict) Console.WriteLine("{0}: {1} times", v.Key, v.Value);
        }
    }
}
